<template>
  <div class="f-r a-c f-w" style="margin-bottom: 18px">
    <div v-if="fileList.length" class="file-list f-r a-c f-w">
      <div v-for="(file) in fileList" :key="file.fileUrl" class="file-upload file-item" @click="view(file.fileUrl)">
        <div class="f-r a-c" style="height: 100%;position:relative;">
          <div class="upload-icon-box  f-r a-c j-c" style="background-color: #f3f6ff">
            <i class="el-icon-document" style="color: #2752f4" />
          </div>
          <div class="upload-text-box f-c j-c f-g" style="overflow:hidden;" :title="file.fileName">
            <div class="upload-text">{{ file.fileName }}</div>
            <div class="upload-unit">点击查看</div>
          </div>
        </div>
      </div>
    </div>
    <div v-else class="text">暂无文件</div>
  </div>
</template>

<script>
export default {
  name: 'FileView',
  props: {
    fileList: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
    }
  },
  methods: {
    view(url) {
        window.open(url, '_black')
    }
  }
}
</script>

<style lang="scss">
.file-upload {
    width: 330px;
    height: 80px;
    border-radius: 14px;
    border: 1px dashed #d9d9d9;
    background-color: #f3f6ff;
    padding: 10px;
    margin-right: 20px;
    margin-bottom: 20px;
    .el-upload {
        display: block;
    }
    .upload-icon-box {
        flex-shrink: 0;
        width: 60px;
        height: 60px;
        border-radius: 12px;
        background-color:#2752f4;
        color: #ffffff;
        font-size: 32px;
        margin-right: 20px;
    }
    .upload-text-box {
        height: 100%;
        text-align: left;
        cursor: pointer;
        .upload-text {
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: #2752f4;
            font-size: 20px;
            margin-bottom: 5px;
        }
        .upload-unit {
            color: #666666;
            font-size: 14px;
        }
    }
}
.file-item {
    position: relative;
    background-color: #ffffff;
    border: 1px solid #2752f4;
    .upload-text-box {
        .upload-text {
            color: #333333;
        }
        .upload-unit {
            color: #2752f4;
        }
    }
    .del-box {
        background-color: #f55557;
        border-radius: 50%;
        position: absolute;
        font-size: 20px;
        width: 26px;
        height: 26px;
        top: -10px;
        right: -10px;
        cursor: pointer;
        z-index: 9;
        color: #ffffff;
    }
}

</style>
